#!C:/Profile
# -*-coding:utf-8-*-
import os
import datetime
import pyodbc
import pandas as pd

path = ''
os.chdir(path)
date_fw = (datetime.date.today() + datetime.timedelta(days=-1)).strftime('%Y%m%d')[4:8]
pyodbc.pooling = False
db_conn = pyodbc.connect('DRIVER={Teradata};DBCNAME=IP;UID=USERID;PWD=PASSWORD;QUIETMODE=YES;', ansi=True,
                         autocommit=True)
cur = db_conn.cursor()
query = ""
cur.execute(query)
getrowount = lambda cur: cur.rowcount if hasattr(cur, 'rowcount') else -1  # 取行数
getfields = lambda cur: [dcrp[0] for dcrp in cur.description] if hasattr(cur, 'description') else None  # 取字段
gettypes = lambda cur: [str(dcrp[1]) for dcrp in cur.description] if hasattr(cur, 'description') else None  # 取字段类型
raw_data = cur.fetchall()
data = pd.DataFrame(np.array(raw_data), columns=getfields(cur))  # 输出结果
data = cursor.fetchone()


